package hk.m4s.lr.repair.test.ui.adapter;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import framework.common.Constant;
import framework.common.zanetwork.core.ResponseCallback;
import framework.utils.SharedPreferencesUtils;
import hk.m4s.lr.repair.test.R;
import hk.m4s.lr.repair.test.model.GoodsCarModel;
import hk.m4s.lr.repair.test.model.MyOrderTuiModel;
import hk.m4s.lr.repair.test.model.MyWaiteOrderModel;
import hk.m4s.lr.repair.test.service.AccountSerive;
import hk.m4s.lr.repair.test.ui.user.HuanGoodsHandleActivity;
import hk.m4s.lr.repair.test.ui.user.MyTuioderActivity;
import hk.m4s.lr.repair.test.ui.user.OderHuanDetailActivity;
import hk.m4s.lr.repair.test.ui.user.OderHuanGoodsActivity;
import hk.m4s.lr.repair.test.ui.user.OderReturnGoodsActivity;
import hk.m4s.lr.repair.test.ui.user.OderReturnMoneyActivity;
import hk.m4s.lr.repair.test.ui.user.OrderSmSActivity;
import hk.m4s.lr.repair.test.ui.user.RefundSucessActivity;
import hk.m4s.lr.repair.test.ui.user.ReturnGoodsSucessActivity;
import hk.m4s.lr.repair.test.ui.user.TuiMoneyActivity;
import hk.m4s.lr.repair.test.ui.user.UserReturnGoodsActivity;
import hk.m4s.lr.repair.test.utils.AppTools;
import hk.m4s.lr.repair.test.utils.MoneyTool;
import hk.m4s.lr.repair.test.views.listview.InnerListView;
import okhttp3.Response;

/**
 * @author 退单状态状态（1待商家处理2退款已成功3买家已发货4商家已同意5物流单号已上传状态6商家已收货7退货退款完成状态8商家已重新发货9换货结束10审核不通过11商家待收货）
 */
public class MyTuiOderAdapter extends BaseAdapter {
    private MyTuioderActivity context;
    public List<MyOrderTuiModel.ListBean> items;
    private List<MyWaiteOrderModel> myjiangLiModelList;
    private ItemTuiOrderAdapter adapter;

    public MyTuiOderAdapter(MyTuioderActivity context,
                            List<MyOrderTuiModel.ListBean> items) {
        this.context = context;
        this.items = items;
    }

    public int getCount() {
        return items.size();
    }

    public Object getItem(int position) {
        return getView(position, null, null);
    }

    public long getItemId(int position) {
        return position;
    }

    @SuppressLint("InflateParams")
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(
                    R.layout.list_item_tui_order, null);
            holder = new ViewHolder();
            holder.order_shop_time = (TextView) convertView.findViewById(R.id.order_shop_time);
            holder.order_shop_state = (TextView) convertView.findViewById(R.id.order_shop_state);
            holder.itemList = (InnerListView) convertView.findViewById(R.id.itemList);
            holder.header = (RelativeLayout) convertView.findViewById(R.id.header);
            holder.order_shop_totlaprice = (TextView) convertView.findViewById(R.id.order_shop_totlaprice);
            holder.cancle_order = (Button) convertView.findViewById(R.id.cancle_order);
            holder.orderState = (TextView) convertView.findViewById(R.id.orderState);
            holder.cancle_huan = (Button) convertView.findViewById(R.id.cancle_huan);
            holder.pay_btn = (Button) convertView.findViewById(R.id.pay_btn);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.cancle_order.setTag(position);
        holder.pay_btn.setTag(position);
        holder.cancle_huan.setTag(position);
        holder.header.setTag(position);
        MyOrderTuiModel.ListBean model = items.get(position);
        holder.order_shop_time.setText("服务单号: " + model.getId());
        holder.order_shop_totlaprice.setText(MoneyTool.getLocalMoney(model.getActual_money()));
        if (model.getGoodsInfo() != null) {
            myjiangLiModelList = new ArrayList<>();
            for (MyOrderTuiModel.ListBean.GoodsInfoBean detailBean : model.getGoodsInfo()) {
                MyWaiteOrderModel waiteOrderModel = new MyWaiteOrderModel();
                waiteOrderModel.setTime(AppTools.getStrTime(detailBean.getAddTime()));
                waiteOrderModel.setGoods_id(detailBean.getGoods_id());
                waiteOrderModel.setName(detailBean.getGoods_name());
                waiteOrderModel.setPrice(detailBean.getGoods_price());
                waiteOrderModel.setSize(detailBean.getGoods_color());
                waiteOrderModel.setBuyNum(detailBean.getGoods_num());
                waiteOrderModel.setState(detailBean.getStatus());
                waiteOrderModel.setImg(detailBean.getImg());
                myjiangLiModelList.add(waiteOrderModel);
            }
            adapter = new ItemTuiOrderAdapter(context, myjiangLiModelList);
            holder.itemList.setAdapter(adapter);
        }
        if (model.getType().equals("1")) {//仅退款
            if (model.getReturn_status().equals("1")) {
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_order.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("仅退款");
                holder.orderState.setText("待审核");
                holder.cancle_order.setBackgroundResource(R.drawable.btn_empy_gray);
                holder.cancle_order.setTextColor(Color.parseColor("#777777"));
                holder.cancle_order.setText("取消退款");
                holder.pay_btn.setText("查看详情");
            } else if (model.getReturn_status().equals("2")) {
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("仅退款  退款成功");
                holder.orderState.setText("审核通过");
                holder.cancle_order.setVisibility(View.VISIBLE);
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_red_roud);
                holder.cancle_order.setTextColor(Color.parseColor("#ff3b30"));
                holder.cancle_order.setText("删除订单");
                holder.pay_btn.setText("查看详情");
            }else if (model.getReturn_status().equals("4")) {
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("仅退款  退款成功");
                holder.orderState.setText("审核通过");
                holder.cancle_order.setVisibility(View.VISIBLE);
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_red_roud);
                holder.cancle_order.setTextColor(Color.parseColor("#ff3b30"));
                holder.cancle_order.setText("删除订单");
                holder.pay_btn.setText("查看详情");
            } else if (model.getReturn_status().equals("10")) {
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("仅退款");
                holder.orderState.setText("审核不通过");
                holder.cancle_order.setVisibility(View.GONE);
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_red_roud);
                holder.cancle_order.setTextColor(Color.parseColor("#ff3b30"));
                holder.pay_btn.setText("查看详情");
            }
        } else if (model.getType().equals("2")) {
            if (model.getReturn_status().equals("1")) {
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("退货退款");
                holder.orderState.setText("待商家处理");
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_order.setText("取消售后");
                holder.cancle_order.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_empy_gray);
                holder.cancle_order.setTextColor(Color.parseColor("#777777"));
                holder.pay_btn.setText("查看详情");

            }else if (model.getReturn_status().equals("2")) {
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("退货退款");
                holder.orderState.setText("退款已成功");
                holder.cancle_order.setVisibility(View.VISIBLE);
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_red_roud);
                holder.cancle_order.setTextColor(Color.parseColor("#ff3b30"));
                holder.cancle_order.setText("删除订单");
                holder.pay_btn.setText("查看详情");
            } else if (model.getReturn_status().equals("4")) {
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("退货退款");
                holder.orderState.setText("商家已同意");
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_order.setText("取消售后");
                holder.cancle_order.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_empy_gray);
                holder.cancle_order.setTextColor(Color.parseColor("#777777"));
                holder.pay_btn.setText("上传物流");
            }else if (model.getReturn_status().equals("5")) {
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.orderState.setText("物流单号已上传");
                holder.order_shop_state.setText("退货退款");
                holder.cancle_order.setVisibility(View.GONE);
                holder.pay_btn.setText("查看物流");
            }else if (model.getReturn_status().equals("6")) {
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.orderState.setText("商家已收货");
                holder.order_shop_state.setText("退货退款");
                holder.cancle_order.setVisibility(View.GONE);
                holder.pay_btn.setText("查看详情");
            } else if (model.getReturn_status().equals("3")) {
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.orderState.setText("买家已发货");
                holder.order_shop_state.setText("退货退款");
                holder.cancle_order.setVisibility(View.GONE);
                holder.pay_btn.setText("查看物流");
            } else if (model.getReturn_status().equals("7")) {
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.orderState.setText("退货退款完成");
                holder.order_shop_state.setText("退货退款  售后结束");
                holder.cancle_order.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_red_roud);
                holder.cancle_order.setTextColor(Color.parseColor("#ff3b30"));
                holder.cancle_order.setText("删除订单");
                holder.pay_btn.setText("查看详情");
            } else if (model.getReturn_status().equals("8")) {
                holder.orderState.setText("商家已发货");
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("退货退款");
                holder.cancle_order.setVisibility(View.GONE);
                holder.pay_btn.setText("查看详情");
            } else if (model.getReturn_status().equals("9")) {
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.orderState.setText("退货退款");
                holder.order_shop_state.setText("换货  售后结束");
                holder.cancle_order.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_red_roud);
                holder.cancle_order.setTextColor(Color.parseColor("#ff3b30"));
                holder.cancle_order.setText("删除订单");
                holder.pay_btn.setText("查看详情");
            }else if (model.getReturn_status().equals("10")) {
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("退货退款");
                holder.orderState.setText("审核不通过");
                holder.cancle_order.setVisibility(View.GONE);
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_red_roud);
                holder.cancle_order.setTextColor(Color.parseColor("#ff3b30"));
                holder.pay_btn.setText("查看详情");
            }else if (model.getReturn_status().equals("11")) {
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.orderState.setText("商家待收货");
                holder.order_shop_state.setText("退货退款");
                holder.cancle_order.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_red_roud);
                holder.cancle_order.setTextColor(Color.parseColor("#ff3b30"));
                holder.cancle_order.setText("删除订单");
                holder.pay_btn.setText("查看物流");
            }
        } else {
            if (model.getReturn_status().equals("1")) {
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("换货");
                holder.orderState.setText("待商家处理");
                holder.cancle_order.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_empy_gray);
                holder.cancle_order.setTextColor(Color.parseColor("#777777"));
                holder.cancle_order.setText("取消售后");
                holder.pay_btn.setText("查看详情");
            }else
            if (model.getReturn_status().equals("4")) {
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("换货");
                holder.orderState.setText("商家已同意");
                holder.cancle_order.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_empy_gray);
                holder.cancle_order.setTextColor(Color.parseColor("#777777"));
                holder.cancle_order.setText("取消售后");
                holder.pay_btn.setText("上传物流");
            } else if (model.getReturn_status().equals("3")) {
                holder.orderState.setText("买家已发货");
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("换货");
                holder.cancle_order.setVisibility(View.GONE);
                holder.pay_btn.setText("查看物流");
            }else if (model.getReturn_status().equals("5")) {
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.orderState.setText("物流单号已上传");
                holder.order_shop_state.setText("换货");
                holder.cancle_order.setVisibility(View.GONE);
                holder.pay_btn.setText("查看物流");
            }  else if (model.getReturn_status().equals("6")) {
                holder.orderState.setText("商家已收货");
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("换货");
                holder.cancle_order.setVisibility(View.GONE);
                holder.pay_btn.setText("查看详情");
            } else if (model.getReturn_status().equals("8")) {
                holder.orderState.setText("商家已发货");
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("换货");
                holder.cancle_order.setVisibility(View.GONE);
                holder.pay_btn.setText("查看物流");
            } else if (model.getReturn_status().equals("9")) {
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.orderState.setText("换货结束");
                holder.order_shop_state.setText("换货  售后结束");
                holder.cancle_order.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_red_roud);
                holder.cancle_order.setTextColor(Color.parseColor("#ff3b30"));
                holder.cancle_order.setText("删除订单");
                holder.pay_btn.setText("查看详情");
            }else if (model.getReturn_status().equals("10")) {
                holder.cancle_huan.setVisibility(View.GONE);
                holder.order_shop_state.setText("换货");
                holder.orderState.setText("审核不通过");
                holder.cancle_order.setVisibility(View.GONE);
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_red_roud);
                holder.cancle_order.setTextColor(Color.parseColor("#ff3b30"));
                holder.pay_btn.setText("查看详情");
            }else if (model.getReturn_status().equals("11")) {
                holder.pay_btn.setVisibility(View.VISIBLE);
                holder.cancle_huan.setVisibility(View.GONE);
                holder.orderState.setText("商家待收货");
                holder.order_shop_state.setText("换货");
                holder.cancle_order.setVisibility(View.VISIBLE);
                holder.cancle_order.setBackgroundResource(R.drawable.btn_red_roud);
                holder.cancle_order.setTextColor(Color.parseColor("#ff3b30"));
                holder.cancle_order.setText("删除订单");
                holder.pay_btn.setText("查看物流");
            }
        }

        holder.cancle_order.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int num = (Integer) v.getTag();
                MyOrderTuiModel.ListBean myOrderModel = items.get(num);
                if (myOrderModel.getType().equals("1") && myOrderModel.getReturn_status().equals("1")) {//取消退款
                    //cancellationRefund(myOrderModel.getId(),"1");
                } else if (myOrderModel.getType().equals("1") && myOrderModel.getReturn_status().equals("2")) {
                   // deleteOrder(myOrderModel.getId());
                } else if (myOrderModel.getType().equals("1") && myOrderModel.getReturn_status().equals("4")) {
                   // deleteOrder(myOrderModel.getId());
                } else if (myOrderModel.getType().equals("2") && myOrderModel.getReturn_status().equals("1")) {//取消售后
                   // cancellationRefund(myOrderModel.getId(),"2");
                } else if (myOrderModel.getType().equals("2") && myOrderModel.getReturn_status().equals("4")) {//取消售后
                   // cancellationRefund(myOrderModel.getId(),"2");
                } else if (myOrderModel.getType().equals("2") && myOrderModel.getReturn_status().equals("7")) {
                   // deleteOrder(myOrderModel.getId());
                }else if (myOrderModel.getType().equals("2") && myOrderModel.getReturn_status().equals("11")) {
                   // deleteOrder(myOrderModel.getId());
                }else if (myOrderModel.getType().equals("3") && myOrderModel.getReturn_status().equals("1")) {//取消售后
                    //cancellationRefund(myOrderModel.getId(),"3");
                }else if (myOrderModel.getType().equals("3") && myOrderModel.getReturn_status().equals("4")) {//取消售后
                   // cancellationRefund(myOrderModel.getId(),"3");
                } else if (myOrderModel.getType().equals("3") && myOrderModel.getReturn_status().equals("9")) {
                   // deleteOrder(myOrderModel.getId());
                }else if (myOrderModel.getType().equals("3") && myOrderModel.getReturn_status().equals("11")) {
                  //  deleteOrder(myOrderModel.getId());
                }
            }
        });
        holder.header.setOnClickListener(new View.OnClickListener()

        {
            @Override
            public void onClick(View v) {
                int num = (Integer) v.getTag();
//                MyOrderTuiModel.ListBean model = items.get(num);
//                Intent aboutIntent = new Intent(context, OderDetailActivity.class);
//                aboutIntent.putExtra("orderId", model.getId());
//                aboutIntent.putExtra("model", model);
//                aboutIntent.putExtra("statuts", "3");
//                context.startActivity(aboutIntent);
            }
        });
        holder.pay_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int num = (Integer) v.getTag();
                MyOrderTuiModel.ListBean myOrderModel = items.get(num);
                if ((myOrderModel.getType().equals("1") && myOrderModel.getReturn_status().equals("1"))) {
                    Intent intent = new Intent(context, OderReturnMoneyActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                }else if ((myOrderModel.getType().equals("1") && myOrderModel.getReturn_status().equals("2"))) {
                    Intent intent = new Intent(context, RefundSucessActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                }else if ((myOrderModel.getType().equals("1") && myOrderModel.getReturn_status().equals("4"))) {
                    Intent intent = new Intent(context, OderReturnMoneyActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                }else if ((myOrderModel.getType().equals("1") && myOrderModel.getReturn_status().equals("10"))) {
                    Intent intent = new Intent(context, OderReturnMoneyActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                } else if (myOrderModel.getType().equals("2") && myOrderModel.getReturn_status().equals("1")) {
                    Intent intent = new Intent(context, OderReturnGoodsActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                } else if (myOrderModel.getType().equals("2") && myOrderModel.getReturn_status().equals("4")) {
                    Intent intent = new Intent(context, HuanGoodsHandleActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                }else if (myOrderModel.getType().equals("2") && myOrderModel.getReturn_status().equals("11")) {//查看物流
                    Intent intent = new Intent(context, OrderSmSActivity.class);
                    intent.putExtra("orderId",  myOrderModel.getId());
                    intent.putExtra("type","1");
                    context.startActivity(intent);
                } else if (myOrderModel.getType().equals("2") && myOrderModel.getReturn_status().equals("3")) {
                    Intent intent = new Intent(context, OrderSmSActivity.class);
                    intent.putExtra("orderId", myOrderModel.getId());
                    intent.putExtra("type","1");
                    context.startActivity(intent);
                }else if (myOrderModel.getType().equals("2") && myOrderModel.getReturn_status().equals("6")) {//取消售后
                    Intent intent = new Intent(context, UserReturnGoodsActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                } else if (myOrderModel.getType().equals("2") && myOrderModel.getReturn_status().equals("7")) {
                    Intent intent = new Intent(context, ReturnGoodsSucessActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                }else if (myOrderModel.getType().equals("2") && myOrderModel.getReturn_status().equals("8")) {//查看物流
                    Intent intent = new Intent(context, OrderSmSActivity.class);
                    intent.putExtra("orderId",  myOrderModel.getId());
                    intent.putExtra("type","1");
                    context.startActivity(intent);
                }else if ((myOrderModel.getType().equals("2") && myOrderModel.getReturn_status().equals("10"))) {
                    Intent intent = new Intent(context, OderHuanDetailActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                }else if (myOrderModel.getType().equals("3") && myOrderModel.getReturn_status().equals("1")) {//取消售后
                    Intent intent = new Intent(context, OderHuanDetailActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                }else if (myOrderModel.getType().equals("3") && myOrderModel.getReturn_status().equals("3")) {//查看物流
                    Intent intent = new Intent(context, OrderSmSActivity.class);
                    intent.putExtra("orderId",  myOrderModel.getId());
                    intent.putExtra("type","1");
                    context.startActivity(intent);
                }else if (myOrderModel.getType().equals("3") && myOrderModel.getReturn_status().equals("4")) {//上传物流
                    Intent intent = new Intent(context, HuanGoodsHandleActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                }else if (myOrderModel.getType().equals("3") && myOrderModel.getReturn_status().equals("6")) {//取消售后
                    Intent intent = new Intent(context, OderHuanGoodsActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                } else if (myOrderModel.getType().equals("3") && myOrderModel.getReturn_status().equals("9")) {
                    Intent intent = new Intent(context, OderHuanDetailActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                }else if (myOrderModel.getType().equals("3") && myOrderModel.getReturn_status().equals("8")) {//查看物流
                    Intent intent = new Intent(context, OrderSmSActivity.class);
                    intent.putExtra("orderId",  myOrderModel.getId());
                    intent.putExtra("type","1");
                    context.startActivity(intent);
                } else if (myOrderModel.getType().equals("3") && myOrderModel.getReturn_status().equals("11")) {//查看物流
                    Intent intent = new Intent(context, OrderSmSActivity.class);
                    intent.putExtra("orderId",  myOrderModel.getId());
                    intent.putExtra("type","1");
                    context.startActivity(intent);
                } else if (myOrderModel.getReturn_status().equals("10")) {
                    Intent intent = new Intent(context, OderHuanDetailActivity.class);
                    intent.putExtra("model", myOrderModel);
                    context.startActivity(intent);
                }
            }
        });
        holder.cancle_huan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int num = (Integer) v.getTag();
                MyOrderTuiModel.ListBean myOrderModel = items.get(num);
                Intent intent = new Intent(context, TuiMoneyActivity.class);
                intent.putExtra("model", myOrderModel);
                context.startActivity(intent);
            }
        });
        return convertView;
    }

    private class ViewHolder {
        TextView order_shop_time;
        TextView order_shop_state;
        TextView order_shop_buynum;
        TextView order_shop_totlaprice;
        TextView orderState;
        ImageView order_shop_img;
        Button cancle_order, pay_btn, cancle_huan;
        private RelativeLayout header;
        InnerListView itemList;
    }

//    public void deleteOrder(String orderId) {
//        Map<String, Object> parmas = new HashMap<>();
//        parmas.put("device_type", Constant.device_type);
//        parmas.put("token", SharedPreferencesUtils.getSharedPreferences(Constant.token, ""));
//        parmas.put("userId", SharedPreferencesUtils.getSharedPreferences(Constant.userId, ""));
//        parmas.put("salesId", orderId);
//        AccountSerive.deleteTuiOrder(context, parmas, new ResponseCallback<GoodsCarModel>() {
//            @Override
//            public void onSuccess(GoodsCarModel model) {
//                context.update();
//            }
//
//            @Override
//            public void onError(Response response, int errorCode, String errorMsg, Exception e) {
//
//            }
//        });
//
//    }
//    public void cancellationRefund(String orderId,String type) {
//        Map<String, Object> parmas = new HashMap<>();
//        parmas.put("device_type", Constant.device_type);
//        parmas.put("token", SharedPreferencesUtils.getSharedPreferences(Constant.token, ""));
//        parmas.put("userId", SharedPreferencesUtils.getSharedPreferences(Constant.userId, ""));
//        parmas.put("salesId", orderId);
//        parmas.put("type",type);
//        AccountSerive.cancellationRefund(context, parmas, new ResponseCallback<GoodsCarModel>() {
//            @Override
//            public void onSuccess(GoodsCarModel model) {
//                context.update();
//            }
//
//            @Override
//            public void onError(Response response, int errorCode, String errorMsg, Exception e) {
//
//            }
//        });
//
//    }
}
